<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('业务系统列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px !important;">业务系统名称：</label>
                                <input type="text" name="businessSystemName"/>
                            </li>
                            <li>
                                <label>分类名称：</label>
                                <input id="categoryCode" name="categoryCode" type="hidden"/>
                                <input class="form-control" type="text" onclick="selectCategoryTree()" id="categoryName" readonly="true">
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="businessSystem:businessSystem:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="businessSystem:businessSystem:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="businessSystem:businessSystem:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="businessSystem:businessSystem:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('businessSystem:businessSystem:edit')}]];
        var removeFlag = [[${@permission.hasPermi('businessSystem:businessSystem:remove')}]];
        var prefix = ctx + "businessSystem/businessSystem";
        function reset() {
            $.form.reset(null, null, null, null, true);
            $("#categoryCode").val(categoryCode);
            $("#categoryName").val(categoryName);
        }
        var prefix2 = ctx + "category/category"
        /*分类体系-新增-选择父分类体系树*/
        function selectCategoryTree() {
            var options = {
                title: '分类体系选择',
                width: "380",
                url: prefix2 + "/selectCategoryTree2/0/1",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }


        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#categoryCode").val(body.find('#treeCode').val());
            $("#categoryName").val(body.find('#treeName').val());
            layer.close(index);

            $.table.search();
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "业务系统",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '业务系统ID',
                    visible: false
                },
                {
                    field: 'businessSystemName',
                    title: '业务系统名称'
                },
                {
                    field: 'businessSystemDescription',
                    title: '业务系统描述'
                },
                {
                    field: 'categoryName',
                    title: '分类节点名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="usageList(\'' + row.id + '\')"><i class="fa fa-edit"></i>关联用况</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function detail(id) {
            $.operate.addTab2("业务系统详情", prefix + "/detail/" + id);
        }
        function usageList(id) {
            var options = {
                title: "关联用况详细",
                width: $(window).width() - 50,
                height: $(window).height() - 50,
                url: prefix + "/usageList?id="+id,
                skin: 'layui-layer-gray',
                btn: ['关闭'],
                yes: function (index, layero) {
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
        }
    </script>
</body>
</html>